#include "CriticalSection.h"

namespace cupid
{
BOOL CriticalSection::Init()
{
	::InitializeCriticalSection(&m_sect);
	return TRUE;
}

CriticalSection::CriticalSection()
{ 	
	Init();
}

CriticalSection::operator CRITICAL_SECTION*()
{ 
	return (CRITICAL_SECTION*) &m_sect; 
}
CriticalSection::~CriticalSection()
{ 
	::DeleteCriticalSection(&m_sect); 
}
BOOL CriticalSection::Lock()
{	
	::EnterCriticalSection(&m_sect); 
	return TRUE; 
}
BOOL CriticalSection::Lock(DWORD dwTimeout)
{
	ASSERT(dwTimeout == INFINITE); 
	return Lock(); 
}
BOOL CriticalSection::Unlock()
{ 
	::LeaveCriticalSection(&m_sect); 
	return TRUE; 
}
}